﻿using System;
using System.Collections.Generic;

namespace Jlvier.TaobaoShowcase.Service
{
    internal class KeyTimes
    {
        private readonly List<KeyTimeSpan> keyTimes = new List<KeyTimeSpan>();

        public static KeyTimes Default
        {
            get 
            { 
                var defaultKeyTimes = new KeyTimes();
                defaultKeyTimes.Add(new KeyTimeSpan(new KeyTime(10),new KeyTime(11)));
                defaultKeyTimes.Add(new KeyTimeSpan(new KeyTime(13), new KeyTime(16)));
                defaultKeyTimes.Add(new KeyTimeSpan(new KeyTime(20), new KeyTime(22)));
                return defaultKeyTimes;
            }
        }

        public void Add(KeyTimeSpan keyTimeSpan)
        {
            keyTimes.Add(keyTimeSpan);
        }

        public bool IsDuringKeyTime(DateTime dateTime)
        {
            foreach(var keyTime in keyTimes)
            {
                if (keyTime.IsDuringKeyTime(dateTime)) return true;
            }
            return false;
        }
    }
}